package applet;

import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.Graphics;

public class AudioApplet extends Applet {

	private static final long serialVersionUID = 1L;
	AudioClip sound; // 声音片断对象

	public void paint(Graphics g) {
		g.drawString("Audio Test", 25, 25);
		//play(getDocumentBase(), "sounds/alarm.au");
	}

	public void init() {
		sound = getAudioClip(getCodeBase(), "../sounds/alarm.au"); // 获得声音片断
		//sound.play();
	}

	public void random() {
		sound.play();
		System.out.println("feefefef");
		for(int i=0;i<10000;i++){
			if(i%1000==0){
				System.out.println(i);
				sound = getAudioClip(getCodeBase(), "sounds/alarm.au");
				sound.play();
			}
		}
	}
	
	public static void main(String[] args) {
		AudioApplet au = new AudioApplet();
		
		au.init();
		au.random();
	}

}
